home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / C Internet Config / Examples ƒ / Example / IC Resource ƒ / Syslog Component ƒ / syslog internals.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-15  |  8.3 KB  |  227 lines  |  [TEXT/SPM ]

  1. /*
  2.     syslog internals.h
  3.     
  4.     Header file
  5.     
  6. */
  7.  
  8. #ifndef __H_Syslog_Internals__
  9. #define __H_Syslog_Internals__
  10.  
  11. #include <Components.h>
  12. #include <Notification.h>
  13. #include <Processes.h>
  14. #include <Packages.h>
  15.  
  16. #ifndef kComponentWildCard
  17. #define kComponentWildCard 0L
  18. #endif
  19.  
  20. typedef struct ComponentStorageStruct ComponentStorageRec,
  21.     * ComponentStoragePtr,** ComponentStorageHdl;
  22.  
  23. #if defined(powerc) || defined (__powerc)
  24. #pragma options align=mac68k
  25. #endif
  26. struct ComponentStorageStruct {
  27.     Component self;
  28.     ComponentInstance kidnapper;
  29.     Component delegate;
  30.     ComponentInstance delegated;
  31.     short resFileRefNum;
  32.     
  33.     // Add component specific storage requirements here
  34.     short refnum;
  35.     FSSpec spec;
  36.     short specvalid;
  37.     short mask;
  38.     short facility;
  39.     long logopts;
  40.     char ident[100];
  41.     
  42.     OSErr err;
  43.     
  44.     // international utilities handle
  45.     Intl0Hndl i0h;
  46.     
  47.     /*
  48.         The following fields are used to remember stuff about the true syslog.
  49.         These are saved when openlog is called and restored when closelog is called.
  50.     */
  51.     
  52.     short vRefNum; // file references
  53.     long dirID;
  54.     
  55.     long slogopts;
  56.     short sfacility;
  57.     short smask;
  58.     
  59.     short openCalled; // to keep track of when to save and when not to save
  60.     short needSaved;
  61. };
  62. #if defined(powerc) || defined(__powerc)
  63. #pragma options align=reset
  64. #endif
  65.  
  66. enum {
  67.     uppCallComponentProcInfo=kPascalStackBased
  68.         | RESULT_SIZE(kFourByteCode)
  69.         | STACK_ROUTINE_PARAMETER(1,kFourByteCode)
  70. };
  71.  
  72. typedef pascal ComponentResult (*CompStorageProcPtr)(Handle storage,ComponentInstance self);
  73. typedef pascal ComponentResult (*CompShortProcPtr)(short count);
  74. typedef pascal ComponentResult (*CompVoidProcPtr)(void);
  75.  
  76. typedef pascal ComponentResult (*CompOpenlogProcPtr)(Handle storage,const char* ident,long logopt,short facility);
  77. typedef pascal ComponentResult (*CompSyslogProcPtr)(Handle storage,short priority,const char* message);
  78. typedef pascal ComponentResult (*CompHandleProcPtr)(Handle storage);
  79. typedef pascal ComponentResult (*CompSetlogmaskProcPtr)(Handle storage,short maskpri);
  80. typedef pascal ComponentResult (*CompSetFileProcPtr)(Handle storage,FSSpecPtr spec);
  81.  
  82. typedef pascal ComponentResult (*CompOSErrPtrProcPtr)(Handle storage,OSErr* err);
  83.  
  84. enum {
  85.     uppCallComponentWithStorageProcInfo=kPascalStackBased
  86.         | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
  87.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Handle)))
  88.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(ComponentInstance))),
  89.     uppCallComponentShortProcInfo=kPascalStackBased
  90.         | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
  91.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(short))),
  92.     uppCallComponentOSErrPtrProcInfo=kPascalStackBased
  93.         | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
  94.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Handle)))
  95.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(OSErr*))),
  96.     uppCallComponentVoidProcInfo=kPascalStackBased
  97.         | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult))),
  98.     uppCallComponentOpenlogProcInfo=kPascalStackBased
  99.         | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
  100.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Handle)))
  101.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(const char*)))
  102.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(long)))
  103.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(short))),
  104.     uppCallComponentHandleProcInfo=kPascalStackBased
  105.         | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
  106.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Handle))),
  107.     uppCallComponentSyslogProcInfo=kPascalStackBased
  108.         | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
  109.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Handle)))
  110.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(short)))
  111.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(const char*))),
  112.     uppCallComponentSetlogmaskProcInfo=kPascalStackBased
  113.         | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
  114.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Handle)))
  115.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(short))),
  116.     uppCallComponentSetFileProcInfo=kPascalStackBased
  117.         | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
  118.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Handle)))
  119.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(FSSpecPtr)))
  120. };
  121.  
  122. #if USESROUTINEDESCRIPTORS
  123. typedef ComponentFunctionUPP ComponentWithStorageUPP;
  124. typedef ComponentFunctionUPP ComponentShortUPP;
  125. typedef ComponentFunctionUPP ComponentVoidUPP;
  126. typedef ComponentFunctionUPP ComponentOpenlogUPP;
  127. typedef ComponentFunctionUPP ComponentSyslogUPP;
  128. typedef ComponentFunctionUPP ComponentHandleUPP;
  129. typedef ComponentFunctionUPP ComponentSetlogmaskUPP;
  130. typedef ComponentFunctionUPP ComponentSetFileUPP;
  131. typedef ComponentFunctionUPP ComponentOSErrPtrUPP;
  132.  
  133. #define CallComponentWithStorageProc(routine,sto,self)\
  134.     CallUniversalProc((UniversalProcPtr)routine,uppCallComponentWithStorageProcInfo,(sto),(self))
  135. #define NewComponentWithStorageProc(routine)\
  136.     (ComponentWithStorageUPP)NewRoutineDescriptor((ProcPtr)routine,uppCallComponentWithStorageProcInfo,GetCurrentISA())
  137.  
  138. #define CallComponentShortProc(routine,val)\
  139.     CallUniversalProc((UniversalProcPtr)routine,uppCallComponentShortProcInfo,(val))
  140. #define NewComponentShortProc(routine)\
  141.     (ComponentShortUPP)NewRoutineDescriptor((ProcPtr)routine,uppCallComponentShortProcInfo,GetCurrentISA())
  142.  
  143. #define CallComponentVoidProc(routine)\
  144.     CallUniversalProc((UniversalProcPtr)routine,uppCallComponentVoidProcInfo)
  145. #define NewComponentVoidProc(routine)\
  146.     (ComponentVoidUPP)NewRoutineDescriptor((ProcPtr)routine,uppCallComponentVoidProcInfo,GetCurrentISA())
  147.  
  148. #define NRD(routine,procinfo) NewRoutineDescriptor((ProcPtr)routine,procinfo,GetCurrentISA())
  149.  
  150. #define NewComponentOpenlogProc(routine) \
  151.     (ComponentOpenlogUPP)NRD((routine),uppCallComponentOpenlogProcInfo)
  152. #define NewComponentSyslogProc(routine) \
  153.     (ComponentSyslogUPP)NRD((routine),uppCallComponentSyslogProcInfo)
  154. #define NewComponentHandleProc(routine) \
  155.     (ComponentHandleUPP)NRD((routine),uppCallComponentHandleProcInfo)
  156. #define NewComponentSetlogmaskProc(routine) \
  157.     (ComponentSetlogmaskUPP)NRD((routine),uppCallComponentSetlogmaskProcInfo)
  158. #define NewComponentSetFileProc(routine) \
  159.     (ComponentSetFileUPP)NRD((routine),uppCallComponentSetFileProcInfo)
  160. #define NewComponentOSErrPtrProc(routine) \
  161.     (ComponentOSErrPtrUPP)NRD((routine),uppCallComponentOSErrPtrProcInfo)
  162.  
  163. #else
  164. typedef CompStorageProcPtr ComponentWithStorageUPP;
  165. typedef CompShortProcPtr ComponentShortUPP;
  166. typedef CompVoidProcPtr ComponentVoidUPP;
  167. typedef CompOpenlogProcPtr ComponentOpenlogUPP;
  168. typedef CompSyslogProcPtr ComponentSyslogUPP;
  169. typedef CompHandleProcPtr ComponentHandleUPP;
  170. typedef CompSetlogmaskProcPtr ComponentSetlogmaskUPP;
  171. typedef CompSetFileProcPtr ComponentSetFileUPP;
  172. typedef CompOSErrPtrProcPtr ComponentOSErrPtrUPP;
  173.  
  174. #define CallComponentWithStorageProc(routine,sto,self)\
  175.     (*routine)((sto),(self))
  176. #define NewComponentWithStorageProc(routine)\
  177.     (ComponentWithStorageUPP)(routine)
  178.  
  179. #define CallComponentShortProc(routine,val)\
  180.     (*routine)((val))
  181. #define NewComponentShortProc(routine)\
  182.     (ComponentShortUPP)(routine)
  183.  
  184. #define CallComponentVoidProc(routine)\
  185.     (*routine)()
  186. #define NewComponentVoidProc(routine)\
  187.     (ComponentVoidUPP)(routine)
  188.  
  189. #define NRD(routine,val) (routine)
  190.  
  191. #define NewComponentOpenlogProc(routine) \
  192.     (ComponentOpenlogUPP)NRD((routine),uppCallComponentOpenlogProcInfo)
  193. #define NewComponentSyslogProc(routine) \
  194.     (ComponentSyslogUPP)NRD((routine),uppCallComponentSyslogProcInfo)
  195. #define NewComponentHandleProc(routine) \
  196.     (ComponentHandleUPP)NRD((routine),uppCallComponentHandleProcInfo)
  197. #define NewComponentSetlogmaskProc(routine) \
  198.     (ComponentSetlogmaskUPP)NRD((routine),uppCallComponentSetlogmaskProcInfo)
  199. #define NewComponentSetFileProc(routine) \
  200.     (ComponentSetFileUPP)NRD((routine),uppCallComponentSetFileProcInfo)
  201. #define NewComponentOSErrPtrProc(routine) \
  202.     (ComponentOSErrPtrUPP)NRD((routine),uppCallComponentOSErrPtrProcInfo)
  203.  
  204. #endif
  205.  
  206. #define DisposeComponentWithStorageProc(routine)\
  207.     DisposeRoutineDescriptor((UniversalProcPtr)routine)
  208. #define DisposeComponentShortProc(routine)\
  209.     DisposeRoutineDescriptor((UniversalProcPtr)routine)
  210. #define DisposeComponentVoidProc(routine)\
  211.     DisposeRoutineDescriptor((UniversalProcPtr)routine)
  212.  
  213. #define DRD(routine) DisposeRoutineDescriptor((UniversalProcPtr)routine)
  214.  
  215. #define DisposeComponentOpenlogProc(routine) DRD(routine)
  216. #define DisposeComponentSyslogProc(routine) DRD(routine)
  217. #define DisposeComponentHandleProc(routine) DRD(routine)
  218. #define DisposeComponentSetlogmaskProc(routine) DRD(routine)
  219. #define DisposeComponentSetFileProc(routine) DRD(routine)
  220. #define DisposeComponentOSErrPtrProc(routine) DRD(routine)
  221.  
  222. #endif /* __H_Syslog_Internals__ */
  223.  
  224.  
  225.  
  226.  
  227.